# 作者: spy
# 开发时间: 2021/12/14 10:06
import time

from selenium.webdriver.common.by import By

from base.base_page import BasePage
from pageobject.login_page import LoginPage
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class InfoDisplay(BasePage):
    """拖车信息展示页面"""
    # 页面元素
    trailer_ID_loc = (By.ID, "trailer_ID")  # 输入拖车号
    search_loc = (By.XPATH, "//form//button[@class='ant-btn ant-btn-primary']")  # 查询按钮

    # 页面动作
    def search_trailer(self, trailer_ID):  # 搜索
        # 登录
        lp = LoginPage(self.driver)
        lp.login_TTOS("admin", "ant.design")
        # 查询拖车信息
        # 等待元素加载完成
        WebDriverWait(self.driver, 30).until(
            EC.visibility_of_element_located((By.ID, "trailer_ID")))
        self.set_keys(InfoDisplay.trailer_ID_loc, trailer_ID)
        WebDriverWait(self.driver, 30).until(
            EC.visibility_of_element_located((By.XPATH, "//form//button[@class='ant-btn ant-btn-primary']")))
        self.click(InfoDisplay.search_loc)


